#!/bin/sh

ENABLED=yes
PROCS=syncthing
ARGS=""
PREARGS=""
DESC=$PROCS
PATH=/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

. /opt/etc/init.d/rc.func

if [ ! -d /opt/etc/syncthing ]; then
   syncthing -generate="/opt/etc/syncthing"
   sed -i 's|127.0.0.1:8384|0.0.0.0:8384|' /opt/etc/syncthing/config.xml
elif [[ -f /opt/etc/syncthing/config.xml ]]; then
   sed -i 's|127.0.0.1:8384|0.0.0.0:8384|' /opt/etc/syncthing/config.xml
fi
